﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using monitor_2_DBwork;

namespace monitor_server_2
{
    static class Program
    {
        /// <summary>
        /// Главная точка входа для приложения.
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            //CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("ru-RU");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppDomain.CurrentDomain.UnhandledException += dom_UnhandledException;
            Application.Run(new Main());
            
        }

        static void dom_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.ExceptionObject.ToString(), @"Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            File.WriteAllText("ErrorLog.txt", "\r\n\r\n--- " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " ---\r\n" + e.ExceptionObject);
            ServerLib.Server.WriteToLog(e.ExceptionObject.ToString(), ServerCategories.SystemError);
        }
    }
}
